def parse_bluetooth_data(data: bytes):
    # 确保数据长度足够
    if len(data) < 106:
        raise ValueError("Data length is insufficient.")
    
    # 第一个字节是通道号
    channel_number = data[0]
    
    # 3-6字节是大端方式传的索引
    index = int.from_bytes(data[2:6], byteorder='big')
    bluetooth_data_set = []
    for i in range(6, 106, 2):
        # 6-105字节是数据
        # 两个字节一个数据
        # 用小端方式解析
        bluetooth_data = int.from_bytes(data[i:i+2], byteorder='little')
        #以毫伏为单位
        bluetooth_data = (bluetooth_data/65535-0.5)*2.5*1000000/2080
        bluetooth_data_set.append(bluetooth_data)
    return channel_number, index, bluetooth_data_set
        
def parse_ppg_data(data: bytes):
    red_led_data = int.from_bytes(data[0:3], byteorder='big')
    ir_led_data = int.from_bytes(data[3:6], byteorder='big')
    return red_led_data, ir_led_data

def parse_imu_data(data: bytes):
    # posture = int.from_bytes(data[0], byteorder='big')
    posture = data[0]
    x = int.from_bytes(data[1:3], byteorder='big')
    y = int.from_bytes(data[3:5], byteorder='big')
    z = int.from_bytes(data[5:7], byteorder='big')
    return posture, x, y, z